#ifndef DEVICEDLG_HPP
#define DEVICEDLG_HPP

#include <QDialog>
#include <QtDBus>
#include "servicesproxymodel.h"
#include "common.hpp"
class QDBusViewModel;
namespace Ui {
class DeviceDlg;
}

class DeviceDlg : public QDialog
{
    Q_OBJECT

public:
    explicit DeviceDlg(QWidget *parent = 0);
    ~DeviceDlg();

    QDBusConnection bus() const;
    QString getCurrentService() const;

    QString getCurrentPath() const;

    QString getCurrentInterface() const;

public slots:
    void on_cbType_currentTextChanged(const QString &text);
private slots:
    void serviceChanged(const QModelIndex &index);
    void on_pushButton_clicked();

    void on_btOk_clicked();

    void on_btCancel_clicked();

    bool connect2DBus();

    void pathChanged(const QModelIndex &index);
private:
    Ui::DeviceDlg *ui;
    QDBusConnection m_bus;
    QString currentService;
    QString currentPath;
    QString currentInterface;
//    void saveSettings();
//    void restoreSettings();
    void saveState() const;
    void restoreSettings();

    QStringListModel *servicesModel;
    ServicesProxyModel *servicesProxyModel;

    QDBusViewModel *pathsModel;
    ServicesProxyModel *pathsProxyModel;

    // QWidget interface
protected:
    void closeEvent(QCloseEvent *event) override;
    void showEvent(QShowEvent *event) override;

    // QWidget interface
protected:
    void hideEvent(QHideEvent *event) override;
};













#endif // DEVICEDLG_HPP
